package com.kaili.basic.service.impl;

import com.baomidou.mybatisplus.service.IService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.kaili.basic.mapper.BaseInStoreDetailMapper;
import com.kaili.basic.mapper.BaseInStoreMapper;
import com.kaili.basic.pojo.dto.BaseInStoreDetailAddDto;
import com.kaili.basic.pojo.entity.BaseInStoreDetailEntity;
import com.kaili.basic.pojo.entity.BaseInStoreEntity;
import com.kaili.basic.pojo.vo.BaseInStoreDetailVO;
import com.kaili.basic.service.BaseInStoreDetailService;
import com.kaili.basic.service.BaseInStoreService;
import com.kaili.common.util.LoginDetailUtils;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class BaseInStoreDetailServiceImpl extends ServiceImpl<BaseInStoreDetailMapper, BaseInStoreDetailEntity> implements BaseInStoreDetailService {

    @Autowired
    private BaseInStoreDetailMapper baseInStoreDetailMapper;
    @Override
    public void bathInsert(List<BaseInStoreDetailAddDto> detailList,String orderNo) {
        for (BaseInStoreDetailAddDto detailDto:detailList) {
            BaseInStoreDetailEntity detailEntity=new BaseInStoreDetailEntity();
            BeanUtils.copyProperties(detailDto,detailEntity);
            detailEntity.setOrderNo(orderNo);
            detailEntity.setCreateBy(LoginDetailUtils.getCurrentEmployeeId().longValue());
            detailEntity.setCreateTime(new Date());
            this.insert(detailEntity);
        }
    }

    @Override
    public List<BaseInStoreDetailVO> queryDetailByOrderNo(HashMap<String, Object> map) {
        return baseInStoreDetailMapper.queryDetailByOrderNo(map);
    }
}
